package com.openbravo.pos.base;

import java.io.File;
import java.util.List;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.I_Session;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import cn.ekuma.epos.datalogic.I_DataLogicSystem;
import cn.ekuma.rabbit.ModelManager;
import cn.ekuma.rabbit.imp.AbstractApp;

public abstract class AbstractPosApp extends AbstractApp {

	public final static PluginManager pmf = PluginManagerFactory.createPluginManager();
	protected I_Session session;
	
	protected I_DataLogicSystem m_dlSystem;
	
	public AbstractPosApp(AppProperties props) {
		super(new ModelManager(pmf,props));
		pmf.addPluginsFrom(new File("plugins/").toURI());
	}

   public abstract boolean initLocalModel();
	
	public void stop() {
		if(session!=null)
		   session.close();
		super.stop();
	}
	
	
	public void initLoger(String name, String host) {
		//DataLogicLoger.init(session, name, host);
	}
	

	protected String readDataBaseVersion(String modeName) {
        try {
            return m_dlSystem.findVersion(modeName);
        } catch (BasicException ed) {
        	ed.printStackTrace();
            return null;
        }
    }

	public I_DataLogicSystem getM_dlSystem() {
		return m_dlSystem;
	}

	protected abstract List exeSQLScript(String sScript) throws BasicException;

}


